
$(document).ready(function(){
	WantAllInfo();
	GoToPay();
});
//请求所有订单信息
var WantAllInfo = function(){
	var orderid = $("div.rentrepay_hidden_orderid").text();
	//模拟数据
//	var orderid = "afecc59d714d46d69149c331fa2ec3dc";
	$.ajax({	
		dataType : "json",
		type : "post",
		url : basePath+"/car/carorderinfo",
		data : {
			orderid:orderid
		},
		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			var num = "订单号：" + data.data.num;
			var imgurl = data.data.imgurl;
			var title = data.data.title;
			var transmission = data.data.transmission;
			var passengers = "荷载" + data.data.passengers + "人";
			var bed = "床位" + data.data.bed + "个";
			var start = data.data.begindate + " "+ data.data.begintime;
			var end = data.data.enddate + " "+ data.data.endtime;
			var city = data.data.city;
			var name = data.data.name;
			var phone = data.data.phone;
			var email = data.data.email;
			var price = data.data.price;
			var state = data.data.state;
			
			$("div.rentrepay_sign_order_down").text(num);
			$("img.rentrepay_info_pic_posi").attr("src",imgurl);
			$("div.rentrepay_info_detail_top_title").text(title);
			$("div.rentrepay_info_detail_top_item:eq(0)").text(transmission);
			$("div.rentrepay_info_detail_top_item:eq(1)").text(passengers);
			$("div.rentrepay_info_detail_top_item:eq(2)").text(bed);
			$("div.rentrepay_info_detail_pick_info_up:eq(0)").text(start);
			$("div.rentrepay_info_detail_pick_info_up:eq(1)").text(end);
			$("div.rentrepay_info_detail_pick_info_down").text(city);
			$("div.rentrepay_contacts_two_item_detail:eq(0)").text(name);
			$("div.rentrepay_contacts_two_item_detail:eq(1)").text(phone);
			$("div.rentrepay_contacts_two_item_detail:eq(2)").text(email);
			$("div#orderallprice").text(price);
			//设置title
			$(document).attr("title","订单填写_"+title);//修改title值  
			
			var p = "";
			for(var i = 0;i<data.data.orderdetail.length;i++){
				p = p +   "<div class=\"rentrepay_info_price_detail_item\">\n"+
								"<div class=\"rentrepay_info_price_detail_item_one\">"+data.data.orderdetail[i].name+"</div>\n"+
								"<div class=\"rentrepay_info_price_detail_item_two\"></div>\n"+
								"<div class=\"rentrepay_info_price_detail_item_three\">\n"+
									"<div class=\"rentrepay_info_price_detail_item_three_sign\"></div>\n"+
									"<div class=\"rentrepay_info_price_detail_item_three_price\">"+data.data.orderdetail[i].price+"</div>\n"+
								"</div>\n"+
							"</div>"
			};
			console.log("p="+p);
			$("div.rentrepay_info_price_detail").html(p);
			
			if(state == "2"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单待确认");
			};
			if(state == "3"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单预定成功");
			};
			if(state == "4"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单出行中");
			};
			if(state == "5"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单已完成");
			};
			if(state == "6"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单确认完成");
			};
			if(state == "7"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单申请退款中");
			};
			if(state == "8"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单退款成功");
			};
		},
		error : function() {
			console.log("访问失败");
		},
		complete : function() {
			layer.close(LoadingIcon);
		},
	});
}
//点击立即支付跳转订单支付页面
var GoToPay = function(){
	$("input.rentrepay_sign_nav_b").click(function(){
		var orderid = $("div.rentrepay_hidden_orderid").text();
		url = basePath+"/rentpay?rentorderid="+orderid;
		window.open(url);
	});
}